import Vue from 'vue'
import Router from 'vue-router'
// 二级路由
import Details from './views/Details'
import Edit from './views/Edit'
// 一级路由 放在最下面
const Home = () => import('./views/home/Home')
const About = () => import('./views/About')
const Add = () => import('./views/Add')

Vue.use(Router)

export default new Router({
  mode: 'history',
  // base: process.env.BASE_URL,
  routes: [
    {
      path: '*',
      redirect: '/home' // 路由重定向
    },
    {
      path: '/home',
      name: 'Home',
      component: Home
    },
    {
      path: '/about',
      name: 'About',
      component: About
    },
    {
      path: '/add',
      name: 'Add',
      component: Add
    },
    {
      path: '/details/:id', // 详情页跳转+id
      name: 'Details',
      component: Details
    },
    {
      path: '/edit/:id', // 详情页跳转+id
      name: 'Edit',
      component: Edit
    }

  ]
})
